<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>文件上传</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
  </head>
  <body>
    <div class="container mt-5">
      <h1 class="mb-4">文件上传</h1>

      {% if message %}
      <div class="alert alert-success" role="alert">{{ message }}</div>
      {% endif %}

      <form method="post" enctype="multipart/form-data">
        <div class="mb-3">
          <label for="file" class="form-label">选择文件</label>
          <input
            class="form-control"
            type="file"
            id="file"
            name="file"
            required
          />
        </div>
        <button type="submit" class="btn btn-primary">上传</button>
      </form>

      {% if file_info %}
      <div class="mt-5">
        <h3>文件信息</h3>
        <ul class="list-group">
          <li class="list-group-item">文件名: {{ file_info.filename }}</li>
          <li class="list-group-item">文件大小: {{ file_info.size }}</li>
          <li class="list-group-item">
            下载链接:
            <a
              href="{{ url_for('download_file', filename=file_info.filename) }}"
            >
              {{ url_for('download_file', filename=file_info.filename) }}
            </a>
          </li>
        </ul>
      </div>
      {% endif %}
    </div>
  </body>
</html>
